package com.smartstate.EnvironmentMonitor.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smartstate.EnvironmentMonitor.dto.ReportDTO;
import com.smartstate.EnvironmentMonitor.entity.Report;
import com.smartstate.EnvironmentMonitor.vo.DataVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
@DS("tdengine")
public interface HistoryMapper extends BaseMapper<Report> {

//    List<String> queryHistoryData(@Param("id") String deviceId, @Param("attribute") String attribute, @Param("reportDTO") ReportDTO reportDTO);

    /**
     * 查询历史数据
     * @param id
     * @param reportDTO
     * @return
     */
    List<Report> queryHistoryData(@Param("id") String id,  @Param("reportDTO") ReportDTO reportDTO, String nowDate);

    /**
     * 获取59条历史数据
     * @param id
     * @return
     */
    List<Report>getHistoryCurveByDeviceId(@Param("id") String id, String startDate, String nowDate);


    /**
     * 查询超级表下的所有子表
     * @param table
     * @return
     */
    @Select("select distinct(equipment_id) from ${table}")
    List<String> queryTable(@Param("table") String table);

    /**
     * 查询表是否存在
     * @param table
     * @return
     */
    @Select("show tables like sh_${table}")
    String queryTableIsEmpty(@Param("table") String table);


}
